<template>
  <div>
    <h1>
      当前的值：{{ $store.state.counter.count }}
      {{ $store.getters["counter/oddOrEven"] }}
    </h1>
    <select v-model="val">
      <option :value="1">1</option>
      <option :value="2">2</option>
      <option :value="3">3</option>
      <option :value="4">4</option>
    </select>
    <button @click="handleIncrement">+</button>
    <button @click="handleDecrement">-</button>
    <button @click="handleIfOddIncrement">如果是奇数就加</button>
    <button @click="handleIncrementAsync">延迟1s加</button>
    
  </div>
</template>

<script>

export default {
  name: "App",
  data(){
    return {
      val: 1,
    }
  },
  methods:{
    handleIncrement(){
      this.$store.dispatch("counter/increment",this.val);
    },
    handleDecrement(){
        this.$store.dispatch("counter/decrement",this.val);
    },
    handleIfOddIncrement(){
       this.$store.dispatch("counter/ifOddIncrement",this.val);
    },
    handleIncrementAsync(){
      this.$store.dispatch("counter/incrementAsync",this.val);
    }
  }
};

</script>

